package cn.swust.designpatternlearningplatform.dao.sql;

import org.apache.ibatis.jdbc.SQL;

import java.time.LocalDateTime;

public class TeacherTestDaoSql {
    /**
     * @param semester:
    	 * @param teacherNumber:
      * @return String
     * @author wang
     * description 查找试卷
     * date 2023/5/17 14:44
     */
    public String getPaperListBySemester(String semester, String teacherNumber){
        return new SQL(){
            {
                SELECT("*");
                FROM("test_paper");
                WHERE("semester=#{semester}","teacher_number=#{teacherNumber}");
            }
        }.toString();
    }
/**
 * @param paperNumber:
  * @return String
 * @author wang
 * description 通过查找学生的在试卷结果里面的学号来判断该类试卷的做题人数
 * date 2023/5/17 14:48
 */
    public String getCompeleteStudent(String paperNumber){
        return new SQL(){
            {
               SELECT("student_number");
               FROM("paper_result");
               WHERE("paper_number=#{paperNumber}");
            }
        }.toString();
    }
    public String getPaperList(String teacherNumber){
        return new  SQL(){
            {
                SELECT("*");
                FROM("test_paper");
                WHERE("teacher_number=#{teacherNumber}");
            }
        }.toString();
    }
    public  String  updatePaperPublishState(String s, String paperId, LocalDateTime time){

        return new SQL(){
            {
                UPDATE("test_paper");
                SET("is_publish=#{s}","publishTime=#{time}");
                WHERE("paper_number=#{paperId}");
            }
        }.toString();
    }
}
